// 定义
class Person {
  name: string;
  age: number;
  code?: string;
  constructor(name: string, age: number = 0) {
    this.name = name
    this.age = age
  }
  say() {
    console.log(this.name, this.age, this.code)
  }
}

const p1 = new Person('sun', 2);
const p2 = new Person('hua');
p1.say()
p2.say()

// 继承
class Student extends Person {
  school?: string = '汉川一中';
  constructor(name: string, age: number, school?: string) {
    super(name, age)
    this.school = school
  }
  study() {
    console.log(this.name + ',年龄:' + this.age + ',正在学习...')
  }
}
class Teacher extends Student {
  price?: number;
  constructor(name: string, age: number, price?: number) {
    super(name, age, '孝感学院')
    this.price = price
  }
  study(): void {
    super.study();
    console.log(this.name + '正在备课,是' + this.school + '的,我的工资是' + this.price)
  }
}

const s1 = new Student('孙远杰', 33)
s1.say()
s1.study()

const t1 = new Teacher('李怡然', 24, 15000)
t1.say()
t1.study()

